/// <summary>
        /// Draw a marquee-tool.
        /// </summary>
        /// <param name="drawingSession"> The drawing-session. </param>
        /// <param name="resourceCreator"> The resource-creator. </param>
        /// <param name="toolType"> The marquee-tool type. </param>
        /// <param name="marqueeTool"> The marquee-tool. </param>
        /// <param name="matrix"> The matrix. </param>
        public static void DrawMarqueeTool(this CanvasDrawingSession drawingSession, ICanvasResourceCreator resourceCreator, MarqueeToolType toolType, MarqueeTool marqueeTool, Matrix3x2 matrix)
        {
            if (marqueeTool.IsStarted)
            {
                switch (toolType)
                {
                case MarqueeToolType.Rectangular:
                {
                    TransformerRect transformerRect = marqueeTool.TransformerRect;
                    CanvasGeometry  canvasGeometry  = transformerRect.ToRectangle(resourceCreator, matrix);
                    drawingSession.DrawThickGeometry(canvasGeometry);
                }
                break;

                case MarqueeToolType.Elliptical:
                {
                    TransformerRect transformerRect = marqueeTool.TransformerRect;
                    CanvasGeometry  canvasGeometry  = transformerRect.ToEllipse(resourceCreator, matrix);
                    drawingSession.DrawThickGeometry(canvasGeometry);
                }
                break;

                case MarqueeToolType.Polygonal:
                {
                    Vector2[]      points                  = marqueeTool.Points.ToArray();
                    CanvasGeometry canvasGeometry          = CanvasGeometry.CreatePolygon(resourceCreator, points);
                    CanvasGeometry canvasGeometryTransform = canvasGeometry.Transform(matrix);
                    drawingSession.DrawThickGeometry(canvasGeometryTransform);

                    Vector2 firstPoint = Vector2.Transform(marqueeTool.Points.First(), matrix);
                    Vector2 lastPoint  = Vector2.Transform(marqueeTool.Points.Last(), matrix);
                    drawingSession.DrawNode5(firstPoint);
                    drawingSession.DrawNode5(lastPoint);
                }
                break;

                case MarqueeToolType.FreeHand:
                {
                    Vector2[]      points                  = marqueeTool.Points.ToArray();
                    CanvasGeometry canvasGeometry          = CanvasGeometry.CreatePolygon(resourceCreator, points);
                    CanvasGeometry canvasGeometryTransform = canvasGeometry.Transform(matrix);
                    drawingSession.DrawThickGeometry(canvasGeometryTransform);
                }
                break;
                }
            }
        }
        /// <summary>
        /// Draw a marquee-tool.
        /// </summary>
        /// <param name="drawingSession"> The drawing-session. </param>
        /// <param name="resourceCreator"> The resource-creator. </param>
        /// <param name="toolType"> The marquee-tool type. </param>
        /// <param name="marqueeTool"> The marquee-tool. </param>
        public static void DrawMarqueeTool(this CanvasDrawingSession drawingSession, ICanvasResourceCreator resourceCreator, MarqueeToolType toolType, MarqueeTool marqueeTool)
        {
            if (marqueeTool.IsStarted)
            {
                switch (toolType)
                {
                case MarqueeToolType.Rectangular:
                {
                    Rect rect = marqueeTool.TransformerRect.ToRect();
                    drawingSession.DrawThickRectangle(rect);
                }
                break;

                case MarqueeToolType.Elliptical:
                {
                    Vector2 centerPoint = marqueeTool.TransformerRect.Center;
                    float   width       = marqueeTool.TransformerRect.Width / 2;
                    float   height      = marqueeTool.TransformerRect.Height / 2;

                    drawingSession.DrawThickEllipse(centerPoint, width, height);
                }
                break;

                case MarqueeToolType.Polygonal:
                {
                    Vector2[]      points         = marqueeTool.Points.ToArray();
                    CanvasGeometry canvasGeometry = CanvasGeometry.CreatePolygon(resourceCreator, points);
                    drawingSession.DrawThickGeometry(canvasGeometry);

                    Vector2 firstPoint = marqueeTool.Points.First();
                    Vector2 lastPoint  = marqueeTool.Points.Last();
                    drawingSession.DrawNode5(firstPoint);
                    drawingSession.DrawNode5(lastPoint);
                }
                break;

                case MarqueeToolType.FreeHand:
                {
                    Vector2[]      points         = marqueeTool.Points.ToArray();
                    CanvasGeometry canvasGeometry = CanvasGeometry.CreatePolygon(resourceCreator, points);
                    drawingSession.DrawThickGeometry(canvasGeometry);
                }
                break;
                }
            }
        }
        /// <summary>
        /// Draw bezier-curve by NodeCollection.
        /// </summary>
        /// <param name="drawingSession"> The drawing-session. </param>
        /// <param name="nodeCollection"> The NodeCollection. </param>
        /// <param name="matrix"> The matrix. </param>
        /// <param name="accentColor"> The accent color. </param>
        public static void DrawNodeCollection(this CanvasDrawingSession drawingSession, NodeCollection nodeCollection, Matrix3x2 matrix, Windows.UI.Color accentColor)
        {
            foreach (Node node in nodeCollection)
            {
                switch (node.Type)
                {
                case NodeType.BeginFigure:
                {
                    Vector2 vector = Vector2.Transform(node.Point, matrix);

                    if (node.IsChecked == false)
                    {
                        if (node.IsSmooth == false)
                        {
                            drawingSession.DrawNode3(vector, Windows.UI.Colors.Gold);
                        }
                        else
                        {
                            drawingSession.DrawNode(vector, Windows.UI.Colors.Gold);
                        }
                    }
                    else
                    {
                        if (node.IsSmooth == false)
                        {
                            drawingSession.DrawNode4(vector, Windows.UI.Colors.Gold);
                        }
                        else
                        {
                            //Right
                            Vector2 rightControlPoint = Vector2.Transform(node.RightControlPoint, matrix);
                            drawingSession.DrawLine(vector, rightControlPoint, accentColor);
                            drawingSession.DrawNode5(rightControlPoint, Windows.UI.Colors.Gold);

                            //Left
                            Vector2 leftControlPoint = Vector2.Transform(node.LeftControlPoint, matrix);
                            drawingSession.DrawLine(vector, leftControlPoint, accentColor);
                            drawingSession.DrawNode5(leftControlPoint, Windows.UI.Colors.Gold);

                            drawingSession.DrawNode2(vector, Windows.UI.Colors.Gold);
                        }
                    }
                }
                break;

                case NodeType.Node:
                {
                    Vector2 vector = Vector2.Transform(node.Point, matrix);

                    if (node.IsChecked == false)
                    {
                        if (node.IsSmooth == false)
                        {
                            drawingSession.DrawNode3(vector, accentColor);
                        }
                        else
                        {
                            drawingSession.DrawNode(vector, accentColor);
                        }
                    }
                    else
                    {
                        if (node.IsSmooth == false)
                        {
                            drawingSession.DrawNode4(vector, accentColor);
                        }
                        else
                        {
                            //Right
                            Vector2 rightControlPoint = Vector2.Transform(node.RightControlPoint, matrix);
                            drawingSession.DrawLine(vector, rightControlPoint, accentColor);
                            drawingSession.DrawNode5(rightControlPoint, accentColor);

                            //Left
                            Vector2 leftControlPoint = Vector2.Transform(node.LeftControlPoint, matrix);
                            drawingSession.DrawLine(vector, leftControlPoint, accentColor);
                            drawingSession.DrawNode5(leftControlPoint, accentColor);

                            drawingSession.DrawNode2(vector, accentColor);
                        }
                    }
                }
                break;

                case NodeType.EndFigure:
                    break;
                }
            }
        }