Exemplo n.º 1
0
        public static CameraView3D CreateDefaultFrom(BBOX bounds)
        {
            // if (bounds.IsInvalid) return CreatePerspective(XYZ.UnitZ * 100, XYZ.Zero);

            var center = bounds.MinMaxCenter();
            var from   = bounds.ColumnY() - center;

            from *= 4;

            return(CreatePerspective(from, center));
        }
Exemplo n.º 2
0
        private void tileImageImpl(CanvasBitmap canvasBitmap, int x, int y, int w, int h)
        {
            CanvasImageBrush brush = new CanvasImageBrush(graphics.Device, canvasBitmap);

            brush.ExtendX = CanvasEdgeBehavior.Wrap;
            brush.ExtendY = CanvasEdgeBehavior.Wrap;
            System.Numerics.Matrix3x2 currentTransform = graphics.Transform;
            graphics.Transform = System.Numerics.Matrix3x2.CreateTranslation(x, y);
            graphics.FillRectangle(0, 0, w, h, brush);
            graphics.Transform = currentTransform;
        }
        private void UnprocessedInput_PointerMoved(InkUnprocessedInput sender, PointerEventArgs args)
        {
            switch (this.toolbarMode)
            {
            case ToolbarMode.Erasing:
                if (!this.isErasing)
                {
                    return;
                }
                //bool invalidate = false;

                //draw rectange for eraser
                eraser = new Rect(args.CurrentPoint.Position, new Size(30, 30));

                #region try 2
                InkStroke          newStroke1    = null;
                InkStroke          newStroke2    = null;
                List <InkPoint>    newpoints1    = new List <InkPoint>();
                List <InkPoint>    newpoints2    = new List <InkPoint>();
                InkStrokeContainer newContainer1 = new InkStrokeContainer();
                InkStrokeContainer newContainer2 = new InkStrokeContainer();

                InkStrokeBuilder          creator = new InkStrokeBuilder();
                System.Numerics.Matrix3x2 matr    = System.Numerics.Matrix3x2.Identity;

                foreach (InkStrokeContainer item in this.strokes.ToArray())
                {
                    Rect rect = item.SelectWithLine(this.lastPoint, args.CurrentPoint.Position);
                    if (rect.Width == 0 && rect.Height == 0)
                    {
                        Debug.WriteLine("skipping InkStrokeContainer  from strokes collection");
                        continue;
                    }

                    Debug.WriteLine("ciclyng strokes collection");
                    //Rect rect = item.SelectWithLine(this.lastPoint, args.CurrentPoint.Position);
                    //if (rect.IsEmpty) continue;
                    //if (rect.Width * rect.Height > 0)
                    //{


                    var selectedStrokes = item.GetStrokes();

                    foreach (InkStroke stroke in selectedStrokes)
                    {
                        if (stroke.Selected == false)
                        {
                            continue;
                        }

                        //Debug.WriteLine("ciclyng selectedStrokes");

                        creator.SetDefaultDrawingAttributes(stroke.DrawingAttributes);
                        bool switchToSecond = false;

                        foreach (InkPoint point in stroke.GetInkPoints())
                        {
                            //Debug.WriteLine("ciclyng GetInkPoints");

                            if (eraser.Contains(point.Position) == false)
                            {
                                if (switchToSecond == false)
                                {
                                    newpoints1.Add(point);
                                }
                                else
                                {
                                    newpoints2.Add(point);
                                }
                            }
                            else
                            {
                                switchToSecond = true;
                            }
                        }

                        if (newpoints1.Count > 0)
                        {
                            newStroke1 = creator.CreateStrokeFromInkPoints(newpoints1, matr);

                            if (newStroke1 != null)
                            {
                                if (newContainer1 == null)
                                {
                                    newContainer1 = new InkStrokeContainer();
                                }
                                newContainer1.AddStroke(newStroke1);
                            }
                        }

                        if (newpoints2.Count > 0)
                        {
                            newStroke2 = creator.CreateStrokeFromInkPoints(newpoints2, matr);
                            if (newStroke2 != null)
                            {
                                if (newContainer2 == null)
                                {
                                    newContainer2 = new InkStrokeContainer();
                                }
                                newContainer2.AddStroke(newStroke2);
                            }
                        }
                    }

                    this.strokes.Remove(item);


                    if (newContainer1 != null)
                    {
                        this.strokes.Add(newContainer1);
                    }
                    if (newContainer2 != null)
                    {
                        this.strokes.Add(newContainer2);
                    }
                    //canvas.Invalidate();
                    //invalidate = true;

                    //}
                }


                newStroke1 = null;
                newStroke2 = null;
                newpoints1.Clear();
                newpoints2.Clear();
                newContainer1 = new InkStrokeContainer();
                newContainer2 = new InkStrokeContainer();
                #endregion

                this.lastPoint = args.CurrentPoint.Position;
                args.Handled   = true;
                //if (invalidate)
                //{
                //	this.canvas.Invalidate();
                //}
                //eraser = Rect.Empty;
                canvas.Invalidate();
                break;

            case ToolbarMode.Lasso:
                if (this.isBoundRect)
                {
                    if (args.CurrentPoint.RawPosition.X > 0 && args.CurrentPoint.RawPosition.Y > 0 && args.CurrentPoint.RawPosition.X < this.ActualWidth && args.CurrentPoint.RawPosition.Y < this.ActualHeight)
                    {
                        this.lasso.Points.Add(args.CurrentPoint.RawPosition);
                    }
                }
                if (this.isSelectionDragging)
                {
                    Rect  boundingRect = Rect.Empty;
                    Point upperLeft    = new Point(args.CurrentPoint.RawPosition.X - this.selectionOffset.Width, args.CurrentPoint.RawPosition.Y - this.selectionOffset.Height);
                    if (upperLeft.X > 0 && upperLeft.Y > 0 && upperLeft.X + this.selectionRectangle.Value.Width < this.ActualWidth && upperLeft.Y + this.selectionRectangle.Value.Height < this.ActualHeight)
                    {
                        Point point = new Point(args.CurrentPoint.RawPosition.X - this.selectionDragPoint.X, args.CurrentPoint.RawPosition.Y - this.selectionDragPoint.Y);
                        foreach (InkStrokeContainer item in this.strokes.ToArray())
                        {
                            Rect rect = item.MoveSelected(point);
                            if (rect.Width > 0 && rect.Height > 0)
                            {
                                boundingRect = RectHelper.Union(boundingRect, rect);
                            }
                        }

                        this.DrawBoundingRect(boundingRect);
                    }

                    this.canvas.Invalidate();
                    this.selectionDragPoint = args.CurrentPoint.RawPosition;
                }
                break;
            }
        }
Exemplo n.º 4
0
 public static Transforms.Canvas2DTransform CreateTransformed(PRIMITIVE2D target, POINT2 physicalSize, POINT2 virtualSize, XFORM2 xform)
 {
     return(Transforms.Canvas2DTransform.Create(target, physicalSize, virtualSize, xform));
 }
Exemplo n.º 5
0
 public static Vector2 TransformNormal(Vector2 normal, Matrix3x2 matrix)
 {
     return(new Vector2(
                normal.X * matrix.M11 + normal.Y * matrix.M21,
                normal.X * matrix.M12 + normal.Y * matrix.M22));
 }
Exemplo n.º 6
0
 public static Vector2 Transform(Vector2 position, Matrix3x2 matrix)
 {
     return(new Vector2(
                position.X * matrix.M11 + position.Y * matrix.M21 + matrix.M31,
                position.X * matrix.M12 + position.Y * matrix.M22 + matrix.M32));
 }