コード例 #1
0
 /// <summary>
 /// Private ctor
 /// </summary>
 /// <param name="stylusPoints"></param>
 /// <param name="operations"></param>
 /// <param name="usePressure"></param>
 internal StrokeNodeIterator(StylusPointCollection stylusPoints,
                             StrokeNodeOperations operations,
                             bool usePressure)
 {
     //Note, StylusPointCollection can be null
     _stylusPoints = stylusPoints;
     if (operations == null)
     {
         throw new ArgumentNullException("operations");
     }
     _operations  = operations;
     _usePressure = usePressure;
 }
コード例 #2
0
        /// <summary>
        /// Creates a default enumerator for a given stroke
        /// If using the strokes drawing attributes, pass stroke.DrawingAttributes for the second
        /// argument.  If using an overridden DA, use that instance.
        /// </summary>
        internal static StrokeNodeIterator GetIterator(StylusPointCollection stylusPoints, DrawingAttributes drawingAttributes)
        {
            if (stylusPoints == null)
            {
                throw new System.ArgumentNullException("stylusPoints");
            }
            if (drawingAttributes == null)
            {
                throw new System.ArgumentNullException("drawingAttributes");
            }

            StrokeNodeOperations operations =
                StrokeNodeOperations.CreateInstance(drawingAttributes.StylusShape);

            bool usePressure = !drawingAttributes.IgnorePressure;

            return(new StrokeNodeIterator(stylusPoints, operations, usePressure));
        }
コード例 #3
0
ファイル: StrokeNode.cs プロジェクト: JianwenSun/cc
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="operations">StrokeNodeOperations object created for particular rendering</param>
        /// <param name="index">Index of the node on the stroke spine</param>
        /// <param name="nodeData">StrokeNodeData for this node</param>
        /// <param name="lastNodeData">StrokeNodeData for the precedeng node</param>
        /// <param name="isLastNode">Whether the current node is the last node</param>
        internal StrokeNode(
            StrokeNodeOperations operations,
            int index,
            StrokeNodeData nodeData,
            StrokeNodeData lastNodeData,
            bool isLastNode)
        {
            System.Diagnostics.Debug.Assert(operations != null);
            System.Diagnostics.Debug.Assert((nodeData.IsEmpty == false) && (index >= 0));
          

            _operations = operations;
            _index = index;
            _thisNode = nodeData;
            _lastNode = lastNodeData;
            _isQuadCached = lastNodeData.IsEmpty;
            _connectingQuad = Quad.Empty;
            _isLastNode = isLastNode;
        }
コード例 #4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="operations">StrokeNodeOperations object created for particular rendering</param>
        /// <param name="index">Index of the node on the stroke spine</param>
        /// <param name="nodeData">StrokeNodeData for this node</param>
        /// <param name="lastNodeData">StrokeNodeData for the precedeng node</param>
        /// <param name="isLastNode">Whether the current node is the last node</param>
        internal StrokeNode(
            StrokeNodeOperations operations,
            int index,
            StrokeNodeData nodeData,
            StrokeNodeData lastNodeData,
            bool isLastNode)
        {
            System.Diagnostics.Debug.Assert(operations != null);
            System.Diagnostics.Debug.Assert((nodeData.IsEmpty == false) && (index >= 0));


            _operations     = operations;
            _index          = index;
            _thisNode       = nodeData;
            _lastNode       = lastNodeData;
            _isQuadCached   = lastNodeData.IsEmpty;
            _connectingQuad = Quad.Empty;
            _isLastNode     = isLastNode;
        }
コード例 #5
0
 /// <summary>
 /// Constructor for an incremental node enumerator that builds nodes
 /// from array(s) of points and a given stylus shape.
 /// </summary>
 /// <param name="nodeShape">a shape that defines the stroke contour</param>
 internal StrokeNodeIterator(StylusShape nodeShape)
     : this(null,    //stylusPoints
            StrokeNodeOperations.CreateInstance(nodeShape),
            false)   //usePressure)
 {
 }
コード例 #6
0
 /// <summary>
 /// Constructor for an incremental node enumerator that builds nodes
 /// from StylusPointCollections
 /// called by the IncrementalRenderer
 /// </summary>
 /// <param name="drawingAttributes">drawing attributes</param>
 internal StrokeNodeIterator(DrawingAttributes drawingAttributes)
     : this(null,                                                                    //stylusPoints
            StrokeNodeOperations.CreateInstance((drawingAttributes == null ? null : drawingAttributes.StylusShape)),
            (drawingAttributes == null ? false : !drawingAttributes.IgnorePressure)) //usePressure
 {
 }
コード例 #7
0
ファイル: ErasingStroke.cs プロジェクト: dox0/DotNet471RS3
        private Point[] FilterPoints(Point[] path)
        {
            System.Diagnostics.Debug.Assert(path.Length > 1);
            Point        back2, back1;
            int          i;
            List <Point> newPath = new List <Point>();

            if (_nodeIterator.Count == 0)
            {
                newPath.Add(path[0]);
                newPath.Add(path[1]);
                back2 = path[0];
                back1 = path[1];
                i     = 2;
            }
            else
            {
                newPath.Add(path[0]);
                back2 = _nodeIterator[_nodeIterator.Count - 1].Position;
                back1 = path[0];
                i     = 1;
            }

            while (i < path.Length)
            {
                if (DoubleUtil.AreClose(back1, path[i]))
                {
                    // Filter out duplicate points
                    i++;
                    continue;
                }

                Vector begin = back2 - back1;
                Vector end   = path[i] - back1;
                //On a line defined by begin & end,  finds the findex of the point nearest to the origin (0,0).
                double findex = StrokeNodeOperations.GetProjectionFIndex(begin, end);

                if (DoubleUtil.IsBetweenZeroAndOne(findex))
                {
                    Vector v = (begin + (end - begin) * findex);
                    if (v.LengthSquared < CollinearTolerance)
                    {
                        // The point back1 can be considered as on the line from back2 to the toTest StrokeNode.
                        // Modify the previous point.
                        newPath[newPath.Count - 1] = path[i];
                        back1 = path[i];
                        i++;
#if POINTS_FILTER_TRACE
                        _collinearPointsScreened++;
#endif
                        continue;
                    }
                }

                // Add the surviving point into the list.
                newPath.Add(path[i]);
                back2 = back1;
                back1 = path[i];
                i++;
            }
#if POINTS_FILTER_TRACE
            _totalPointsScreened += path.Length - newPath.Count;
#endif
            return(newPath.ToArray());
        }
コード例 #8
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="operations">StrokeNodeOperations object created for particular rendering</param>
 /// <param name="index">Index of the node on the stroke spine</param>
 /// <param name="nodeData">StrokeNodeData for this node</param>
 /// <param name="lastNodeData">StrokeNodeData for the precedeng node</param>
 /// <param name="isLastNode">Whether the current node is the last node</param>
 internal StrokeNode(
     StrokeNodeOperations operations,
     int index,
     in StrokeNodeData nodeData,
コード例 #9
0
ファイル: StrokeNodeEnumerator.cs プロジェクト: JianwenSun/cc
 /// <summary>
 /// Private ctor
 /// </summary>
 /// <param name="stylusPoints"></param>
 /// <param name="operations"></param>
 /// <param name="usePressure"></param>
 internal StrokeNodeIterator(StylusPointCollection stylusPoints,
                             StrokeNodeOperations operations,
                             bool usePressure)
 {
     //Note, StylusPointCollection can be null
     _stylusPoints = stylusPoints;
     if (operations == null)
     {
         throw new ArgumentNullException("operations");
     }
     _operations = operations;
     _usePressure = usePressure;
 }