Пример #1
0
        /// <summary>
        ///     DrawLine - 
        ///     Draws a line with the specified pen.
        ///     Note that this API does not accept a Brush, as there is no area to fill. 
        /// </summary> 
        /// <param name="pen"> The Pen with which to stroke the line. </param>
        /// <param name="point0"> The start Point for the line. </param> 
        /// <param name="point0Animations"> Optional AnimationClock for point0. </param>
        /// <param name="point1"> The end Point for the line. </param>
        /// <param name="point1Animations"> Optional AnimationClock for point1. </param>
        public override void DrawLine( 
            Pen pen,
            Point point0, 
            AnimationClock point0Animations, 
            Point point1,
            AnimationClock point1Animations) 
        {

        #if DEBUG
            MediaTrace.DrawingContextOp.Trace("DrawLine(animate)"); 
        #endif
 
            // 
            // Verify that parameters & state are valid
            // 

            VerifyApiNonstructuralChange();

            if (pen == null) 
            {
                return; 
            } 

            // 
            // Create a geometry & add animations if they exist
            //

            // Instantiate the geometry 
            LineGeometry geometry = new LineGeometry(point0, point1);
 
            // 
            // We may need to opt-out of inheritance through the new Freezable.
            // This is controlled by this.CanBeInheritanceContext. 
            //

            geometry.CanBeInheritanceContext = CanBeInheritanceContext;
 
            // Setup the geometries freezable-related state
            SetupNewFreezable( 
                geometry, 
                (point0Animations == null) && // Freeze if animations are null
                (point1Animations == null) 
                );

            // Add animations to the geometry
            if (point0Animations != null) 
            {
                geometry.ApplyAnimationClock(LineGeometry.StartPointProperty, point0Animations); 
            } 

            if(point1Animations != null) 
            {
                geometry.ApplyAnimationClock(LineGeometry.EndPointProperty, point1Animations);
            }
 
            //
            // Add Drawing to the Drawing graph 
            // 

            AddNewGeometryDrawing(null, pen, geometry); 
        }