Ejemplo n.º 1
0
        private void AddDraw(CanvasDrawingSession drawingSession)
        {
            ILayer layer = this.CurveLayer;

            Matrix3x2 matrix    = this.ViewModel.CanvasTransformer.GetMatrix();
            Vector2   lastPoint = Vector2.Transform(this._addLastNode.Point, matrix);
            Vector2   endPoint  = Vector2.Transform(this._addEndNode.Point, matrix);


            // Geometry
            ICanvasBrush      canvasBrush = layer.Style.Stroke.GetICanvasBrush(LayerManager.CanvasDevice);
            float             strokeWidth = layer.Style.StrokeWidth;
            CanvasStrokeStyle strokeStyle = layer.Style.StrokeStyle;

            drawingSession.DrawLine(lastPoint, endPoint, canvasBrush, strokeWidth, strokeStyle);


            // Draw
            drawingSession.DrawLine(lastPoint, endPoint, this.ViewModel.AccentColor);
            drawingSession.DrawWireframe(layer, matrix, this.ViewModel.AccentColor);

            drawingSession.DrawNode3(endPoint);
            drawingSession.DrawNodeCollection(layer.Nodes, matrix, this.ViewModel.AccentColor);


            // Snapping
            if (this.IsSnap)
            {
                this.Snap.Draw(drawingSession, matrix);
                this.Snap.DrawNode2(drawingSession, matrix);
            }
        }
Ejemplo n.º 2
0
        private void PreviewDraw(CanvasDrawingSession drawingSession)
        {
            Matrix3x2 matrix   = this.ViewModel.CanvasTransformer.GetMatrix();
            Vector2   lineLeft = Vector2.Transform(this._previewLeft, matrix);

            if (this._hasPreviewTempLeftPoint)
            {
                drawingSession.DrawNode3(lineLeft);
            }
            else
            {
                Vector2 lineRight = Vector2.Transform(this._previewRight, matrix);

                drawingSession.DrawLine(lineLeft, lineRight, this.ViewModel.AccentColor);
                drawingSession.DrawNode3(lineLeft);
                drawingSession.DrawNode3(lineRight);
            }
        }
        /// <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;
                }
            }
        }