packages/Windows API Code Pack 1.1/source/Samples/DirectX/CS/Direct2D/D2DShapes/D2DShapesControl.cs
/// <summary>
/// Peels the top shape at a given point,
/// updates the render targets and puts the peeled shape to the stack of peelings.
/// Used to enable removing a child shape - eg. a top shape in a layer
/// </summary>
/// <param name="point"></param>
/// <param name="shapes"></param>
/// <returns></returns>
Peels the top shape at a given point,
updates the render targets and puts the peeled shape to the stack of peelings.
Used to enable removing a child shape - eg. a top shape in a layer
Peels the top shape at a given point updates the render targets and puts the peeled shape to the stack of peelings . Used to enable removing a child shape - eg . a top shape in a layer
private DrawingShape PeelAtRecursive(Point2F point, IList<DrawingShape> shapes)
        {
            for (int i = shapes.Count - 1; i >= 0; i--)
            {
                if (shapes[i].HitTest(point))
                {
                    if (shapes[i].ChildShapes == null)
                    {
                        string statName = shapes[i].GetType().Name.Replace("Shape", " count");
                        UpdateStats(statName, -1);
                        peelings.Push(shapes[i]);
                        shapes.RemoveAt(i);
                        RefreshAll();
                        return peelings.Peek();
                    }
                    DrawingShape shapePeeled = PeelAtRecursive(point, shapes[i].ChildShapes);
                    if (shapePeeled == null)
                    {
                        string statName = shapes[i].GetType().Name.Replace("Shape", " count");
                        UpdateStats(statName, -1);
                        peelings.Push(shapes[i]);
                        shapes.RemoveAt(i);
                        RefreshAll();
                        return peelings.Peek();
                    }
                    return shapePeeled;
                }
            }
            return null;
        }
private DrawingShape PeelAtRecursive ( Point2F point , IList < DrawingShape > shapes ) { for ( int i = shapes . Count - 1 ; i >= 0 ; i -- ) { if ( shapes [ i ] . HitTest ( point ) ) { if ( shapes [ i ] . ChildShapes == null ) { string statName = shapes [ i ] . GetType ( ) . Name . Replace ( " " , " " ) ; UpdateStats ( statName , - 1 ) ; peelings . Push ( shapes [ i ] ) ; shapes . RemoveAt ( i ) ; RefreshAll ( ) ; return peelings . Peek ( ) ; } DrawingShape shapePeeled = PeelAtRecursive ( point , shapes [ i ] . ChildShapes ) ; if ( shapePeeled == null ) { string statName = shapes [ i ] . GetType ( ) . Name . Replace ( " " , " " ) ; UpdateStats ( statName , - 1 ) ; peelings . Push ( shapes [ i ] ) ; shapes . RemoveAt ( i ) ; RefreshAll ( ) ; return peelings . Peek ( ) ; } return shapePeeled ; } } return null ; }
Peels the top shape at a given point,
updates the render targets and puts the peeled shape to the stack of peelings.
Peels the top shape at a given point updates the render targets and puts the peeled shape to the stack of peelings .
None
point
Point2F
None
shapes
IList<DrawingShape>
None