コード例 #1
0
 private void FinishStroke(GraphicsPolyLine polyLine)
 {
     //Seal stroke for better performance
     //polyLine.Freeze();
     if (polyLine == null)
     {
         return;
     }
     // Remove finished stroke from the collection of strokes in drawing.
     _activeStrokes.Remove(polyLine.DeviceID);
 }
コード例 #2
0
        public override GraphicsBase CreateGraphics()
        {
            GraphicsBase b = new GraphicsPolyLine(points, lineWidth, objectColor, actualScale, layer, page, reportContent, reporter, reportDate);

            if (this.ID != 0)
            {
                b.Id         = this.ID;
                b.IsSelected = this.selected;
            }

            return(b);
        }
コード例 #3
0
        public override GraphicsBase CreateGraphics()
        {
            GraphicsBase b = new GraphicsPolyLine(points, lineWidth, lineStyle, objectColor, actualScale);

            if (this.ID != 0)
            {
                b.Id         = this.ID;
                b.IsSelected = this.selected;
            }

            return(b);
        }
コード例 #4
0
        public PropertiesGraphicsPolyLine(GraphicsPolyLine polyLine)
        {
            if (polyLine == null)
            {
                throw new ArgumentNullException("polyLine");
            }


            points      = polyLine.GetPoints();
            lineWidth   = polyLine.LineWidth;
            objectColor = polyLine.ObjectColor;
            actualScale = polyLine.ActualScale;
            ID          = polyLine.Id;
            selected    = polyLine.IsSelected;
        }
コード例 #5
0
        /// <summary>
        /// Create new object
        /// </summary>
        public override void OnMouseDown(DrawingCanvas drawingCanvas, MouseButtonEventArgs e)
        {
            Point p = e.GetPosition(drawingCanvas);

            newPolyLine = new GraphicsPolyLine(
                new Point[]
            {
                p,
                new Point(p.X + 1, p.Y + 1)
            },
                drawingCanvas.LineWidth,
                drawingCanvas.ObjectColor,
                drawingCanvas.ActualScale);

            AddNewObject(drawingCanvas, newPolyLine);

            lastX = p.X;
            lastY = p.Y;
        }
コード例 #6
0
        public PropertiesGraphicsPolyLine(GraphicsPolyLine polyLine)
        {
            if (polyLine == null)
            {
                throw new ArgumentNullException("polyLine");
            }

            this.points      = polyLine.GetPoints();
            this.lineWidth   = polyLine.LineWidth;
            this.objectColor = polyLine.ObjectColor;
            this.actualScale = polyLine.ActualScale;
            this.ID          = polyLine.Id;
            this.selected    = polyLine.IsSelected;

            this.layer = polyLine.Layer;
            this.page  = polyLine.Page;

            this.reportContent = polyLine.ReportContent;
            this.reporter      = polyLine.Reporter;
            this.reportDate    = polyLine.ReportDate;
        }
コード例 #7
0
        /// <summary>
        /// Create new object
        /// </summary>
        public override void OnMouseDown(DrawingCanvas drawingCanvas, MouseButtonEventArgs e)
        {
            Point p = e.GetPosition(drawingCanvas);

            GestureData.IsTouch = false;
            newPolyLine         = new GraphicsPolyLine(
                new Point[]
            {
                p,
                new Point(p.X + 1, p.Y + 1)
            },
                drawingCanvas.LineWidth,
                drawingCanvas.ObjectColor,
                drawingCanvas.ActualScale);

            AddNewObject(drawingCanvas, newPolyLine);

            lastX = p.X;
            lastY = p.Y;
            System.Diagnostics.Debug.WriteLine("Mousedown");
        }
コード例 #8
0
        public override void OnMouseUp(DrawingCanvas drawingCanvas, MouseButtonEventArgs e)
        {
            newPolyLine = null;

            base.OnMouseUp(drawingCanvas, e);
        }
コード例 #9
0
 public override void OnMouseUp(DrawingCanvas drawingCanvas, MouseButtonEventArgs e)
 {
     newPolyLine = null;
     base.OnMouseUp(drawingCanvas, e);
     System.Diagnostics.Debug.WriteLine("Mouseup");
 }
コード例 #10
0
        // Touch down event handler.
        /// <summary>
        /// 输入一个点,判定是否为手势,是则不需要在继续判断,手指离开时,将手势标识设置为false
        /// 如果不是则继续判断是否为手势.
        /// </summary>
        /// <param name="drawingCanvas"></param>
        /// <param name="e"></param>
        public void TouchDownHandler(DrawingCanvas drawingCanvas, TouchEventArgs e)
        {
            GestureData.Fingers++;//记录手指数
            GraphicsPolyLine polyLine;
            TouchPoint       touchPoint = e.GetTouchPoint(drawingCanvas);
            Point            p          = touchPoint.Position;

            if (GestureData.Fingers == 1)//记录第一个手指的基本信息,后后续手势判断使用
            {
                if (!GestureData.IsSignFoFingerOne)
                {
                    GestureData.IsTouch               = true;
                    GestureData.FirstDeviceId         = e.TouchDevice.Id;
                    GestureData.FirstFingerBeginPoint = p;
                    GestureData.FirstFingerCurPoint   = p;
                    GestureData.IsSignFoFingerOne     = true;
                }
            }

            HelperFunctions.IsGesture(drawingCanvas, e);//判断是否为手势

            //如果是手势,则将第一个手指画的几何型的Candraw属性置为false,使得后续不在画出来
            if (GestureData.IsGesture && GestureData.Fingers == 2 && _activeStrokes.TryGetValue(GestureData.FirstDeviceId, out polyLine))
            {
                polyLine.CanDraw = false;
            }

            if (_activeStrokes.TryGetValue(e.TouchDevice.Id, out polyLine))
            {
                FinishStroke(polyLine);
                return;
            }

            //当手指的个数大于2时,将第一个手指与第二个手指的canDraw属性置回true
            if (!GestureData.IsGesture && GestureData.Fingers > 2)
            {
                if (_activeStrokes.TryGetValue(GestureData.FirstDeviceId, out polyLine))
                {
                    polyLine.CanDraw = true;
                }
                if (_activeStrokes.TryGetValue(GestureData.SecondDeviceId, out polyLine))
                {
                    polyLine.CanDraw = true;
                }
            }

            // Create new stroke, add point and assign a color to it.
            GraphicsPolyLine newPolyLine = new GraphicsPolyLine(
                new Point[]
            {
                p,
                new Point(p.X + 1, p.Y + 1)
            },
                drawingCanvas.LineWidth,
                drawingCanvas.ObjectColor,
                drawingCanvas.ActualScale);

            newPolyLine.DeviceID = e.TouchDevice.Id;
            //是手势并且是第二个手指,将其画的几何的CanDraw置为false,不用画
            if (GestureData.IsGesture && GestureData.Fingers == 2)
            {
                if (!GestureData.IsSignForFingerTwo)
                {
                    GestureData.SecondDeviceId               = e.TouchDevice.Id;
                    GestureData.SecFingerBeginPoint          = p;
                    GestureData.StartDistInTwoFingers        = HelperFunctions.CalcDistanceSquare(GestureData.FirstFingerBeginPoint, GestureData.SecFingerBeginPoint);
                    GestureData.StartCenterPointInTwoFingers = HelperFunctions.getCenterPoint(GestureData.FirstFingerBeginPoint, GestureData.SecFingerBeginPoint);
                    GestureData.SecFingerCurPoint            = p;
                    newPolyLine.CanDraw            = false;
                    GestureData.IsSignForFingerTwo = true;
                    if (GestureData.FirstFingerBeginPoint.X < GestureData.SecFingerBeginPoint.X)
                    {
                        GestureData.MaxPositionX = true;
                    }
                }
            }
            //防止已经是手势了,但因为用户不小心使得其他手指不小心碰到了触控,需要使得该误碰的手写内容不画出来
            if (GestureData.IsGesture && GestureData.Fingers > 2)
            {
                newPolyLine.CanDraw = false;
            }
            AddNewObject(drawingCanvas, newPolyLine);

            // Add new stroke to the collection of strokes in drawing.
            _activeStrokes[newPolyLine.DeviceID] = newPolyLine;

            System.Diagnostics.Debug.WriteLine("Touchdown:{0}", GestureData.IsGesture);
        }