Exemple #1
0
        //描く処理(ペン用)
        private void inkCanvas1_StylusDown(object sender, StylusDownEventArgs e)
        {
            //消しゴムモードなら抜け出す
            if (inkCanvas1.EditingMode == InkCanvasEditingMode.EraseByPoint)
            {
                return;
            }

            UIElement el = sender as UIElement;

            //自由線
            if (isFreeLine)
            {
                dragging = true;
                points   = new List <System.Windows.Point>();
                points.Add(e.GetPosition(el));

                prevP = e.GetPosition(el);
            }

            //直線
            else
            {
                dragging = true;
                startP   = e.GetPosition(el);
            }
        }
Exemple #2
0
 private void paintSurface_StylusDown(object sender, StylusDownEventArgs e)
 {
     if (!isMouseDown)
     {
         Debug.WriteLine("Mouse down from stylus down event: " + e.GetPosition(paintSurface).X + ", " + e.GetPosition(paintSurface).Y);
         MyMouseDown(e.GetPosition(paintSurface));
     }
 }
        /// <summary>
        /// Occurs when the stylus is pressed down on the canvas
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void inkCanvas_StylusDown(object sender, StylusDownEventArgs e)
        {
            if (debug)
            {
                Console.WriteLine("Stylus Down " + sketchPanel.InkCanvas.GetSelectedStrokes().Count);
            }

            if (stylusOverWidget(e.GetPosition(sketchPanel.InkCanvas)))
            {
                return;
            }

            this.hoverTimer.Stop();
            if (widgetsShowing)
            {
                HideAllWidgets();
            }

            if (selectionActive && !editMenu.labelMenuIsOpen)
            {
                this.selector.InkCanvas_StylusDown(sender, e);
            }

            // Make sure we the wait cursor is turned off on the pen down
            sketchPanel.InkCanvas.UseCustomCursor = false;
        }
        protected override void OnStylusDown(StylusDownEventArgs args)
        {
            base.OnStylusDown(args);
            Point ptStylus = args.GetPosition(canv);

            // Создание основного объекта Polyline с закругленными концами отрезков
            polyStylus                    = new Polyline();
            polyStylus.Stroke             = brushStylus;
            polyStylus.StrokeThickness    = widthStroke;
            polyStylus.StrokeStartLineCap = PenLineCap.Round;
            polyStylus.StrokeEndLineCap   = PenLineCap.Round;
            polyStylus.StrokeLineJoin     = PenLineJoin.Round;
            polyStylus.Points             = new PointCollection();
            polyStylus.Points.Add(ptStylus);

            // Созданиеобъекта Polyline для имитации тени
            polyShadow                    = new Polyline();
            polyShadow.Stroke             = brushShadow;
            polyShadow.StrokeThickness    = widthStroke;
            polyShadow.StrokeStartLineCap = PenLineCap.Round;
            polyShadow.StrokeEndLineCap   = PenLineCap.Round;
            polyShadow.StrokeLineJoin     = PenLineJoin.Round;
            polyShadow.Points             = new PointCollection();
            polyShadow.Points.Add(ptStylus + vectShadow);

            //Тень вставляется перед ломаными переднего плана
            canv.Children.Insert(canv.Children.Count / 2, polyShadow);

            //Основная ломаная добавляется последней
            canv.Children.Add(polyStylus);

            CaptureStylus();
            isDrawing    = true;
            args.Handled = true;
        }
        //形状工具
        private void inkContent_StylusDown(object sender, StylusDownEventArgs e)
        {
            StartPoint = e.GetPosition(inkContent);

            System.Windows.Shapes.Path Precttangle = new System.Windows.Shapes.Path();
            TempPath         = Precttangle;
            Precttangle.Name = "Rectangle" + StartPoint.X.ToString();
            if (ShapeSelcted == "0")
            {
                inkContent.Children.Add(Precttangle);
            }

            if (ShapeSelcted == "1")
            {
                inkContent.Children.Add(Precttangle);
            }

            if (ShapeSelcted == "2")
            {
                inkContent.Children.Add(Precttangle);
            }

            if (ShapeSelcted == "3")
            {
                inkContent.Children.Add(Precttangle);
            }
        }
        /// <summary>
        /// Allows the user to connect shapes by dragging a connection
        /// Stylus down gets the endpoint that was clicked, stores it in clickedPoint.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void InkCanvas_StylusDown(object sender, StylusDownEventArgs e)
        {
            if (debug)
            {
                Console.WriteLine("Endpoint stylus down received.");
            }

            System.Windows.Point clickPoint = e.GetPosition(sketchPanel.InkCanvas);

            // Get the endpoint that was clicked
            foreach (EndPointPainter endPoint in endPointPainterMap.Values)
            {
                double distance = Math.Sqrt(Math.Pow(endPoint.InkPoint.X - clickPoint.X, 2) +
                                            Math.Pow(endPoint.InkPoint.Y - clickPoint.Y, 2));

                if (distance <= CLICK_RADIUS)
                {
                    clickedIndex = endPoint.Id;

                    EndPointPainter clickedPoint;
                    endPointPainterMap.TryGetValue((int)clickedIndex, out clickedPoint);

                    if (clickedPoint == null || clickedPoint.EPoint.IsConnected)
                    {
                        clickedIndex = null;
                        return;
                    }

                    sketchPanel.DisableDrawing();
                    break;
                }
            }
        }
Exemple #7
0
        protected override void OnStylusDown(StylusDownEventArgs args)
        {
            base.OnStylusDown(args);
            Point ptStylus = args.GetPosition(canv);

            // Create a Polyline with rounded ends and joins for the foreground.
            polyStylus                    = new Polyline();
            polyStylus.Stroke             = brushStylus;
            polyStylus.StrokeThickness    = widthStroke;
            polyStylus.StrokeStartLineCap = PenLineCap.Round;
            polyStylus.StrokeEndLineCap   = PenLineCap.Round;
            polyStylus.StrokeLineJoin     = PenLineJoin.Round;
            polyStylus.Points             = new PointCollection();
            polyStylus.Points.Add(ptStylus);

            // Another Polyline for the shadow.
            polyShadow                    = new Polyline();
            polyShadow.Stroke             = brushShadow;
            polyShadow.StrokeThickness    = widthStroke;
            polyShadow.StrokeStartLineCap = PenLineCap.Round;
            polyShadow.StrokeEndLineCap   = PenLineCap.Round;
            polyShadow.StrokeLineJoin     = PenLineJoin.Round;
            polyShadow.Points             = new PointCollection();
            polyShadow.Points.Add(ptStylus + vectShadow);

            // Insert shadow before all foreground polylines.
            canv.Children.Insert(canv.Children.Count / 2, polyShadow);

            // Foreground can go at end.
            canv.Children.Add(polyStylus);

            CaptureStylus();
            isDrawing    = true;
            args.Handled = true;
        }
        private void image1_StylusDown(object sender, StylusDownEventArgs e)
        {
            Point pt = e.GetPosition(image1);
            StylusPointCollection sp = e.GetStylusPoints(image1);

            DrawStart(pt, sp[0].PressureFactor);
            e.Handled = true;
        }
 void inqCanvas_PreviewStylusDown(object sender, StylusDownEventArgs e)
 {
     if (Selected.Contents != null && Selected.Contents.Outline != null && Selected.Contents.Outline.GetBounds().Contains(e.GetPosition(inqCanvas)))
     {
         StartMove(e.GetPosition(inqCanvas));
         inqCanvas.InkEnabled = false;
         e.Handled            = true;
     }
 }
 /// <summary>
 /// Event handler for the StylusDown event. Implements a zoom operation for a double tap.
 /// </summary>
 /// <param name="sender">Sender of the StylusDown event.</param>
 /// <param name="e">Event parameters.</param>
 void mapView_StylusDown(object sender, StylusDownEventArgs e)
 {
     if (e.TapCount == 2)
     {
         var p = MapView.CanvasToPtvMercator(MapView.GeoCanvas, e.GetPosition(MapView.GeoCanvas));
         MapView.ZoomAround(p, MapView.FinalZoom + 1, Map.UseAnimation);
         e.Handled = true;
     }
 }
 private async void LessonContainer_StylusDown(object sender, StylusDownEventArgs e)
 {
     // If touch-and-hold (within 9px radius circle, over 700ms)
     if (await TouchHelper.StylusHold(e, LessonContainer, 700, 9))
     {
         // Opens RadialMenu
         LayerStackDC.OpenRadialMenu(LayerStackDC.Viewport.GetViewport(), e.GetPosition(LessonContainer),
                                     RadialMenuState.Levels.Main);
     }
 }
        private void Pad01_StylusDown(object sender, StylusDownEventArgs e)
        {
            Stylus.Capture(Pad01);
            Point pos = e.GetPosition(Pad01);

            dPadPointX   = Pad01.RenderSize.Width / 2;
            dPadPointY   = Pad01.RenderSize.Height / 2;
            dStartPointX = pos.X - dPadPointX;
            dStartPointY = pos.Y - dPadPointY;
            flg          = true;
        }
Exemple #13
0
        protected override void OnPreviewStylusDown(StylusDownEventArgs e)
        {
            if (SetValueStartDrag(
                    x => e.GetPosition(x),
                    x => x.CaptureStylus()))
            {
                e.Handled = true;
            }

            base.OnPreviewStylusDown(e);
        }
        void TouchWindow_PreviewStylusDown(object sender, StylusDownEventArgs e)
        {
            var touchPointSize = TouchDetector.GetSizeFromStylusPoint(e.StylusDevice.GetStylusPoints(this)[0]);

            var touchPoint = new GestureTouchPoint(e.StylusDevice, touchPointSize, e.GetPosition(this), TouchAction.Down);

            _touches.AddOrUpdate(e.StylusDevice.Id, touchPoint,
                                 (key, oldValue) => touchPoint);

            GestureTouchDown(this, new GestureTouchEventArgs(e.StylusDevice.Id, touchPoint, e.Timestamp));
        }
        //描く処理(ペン用)
        private void inkCanvas1_StylusDown(object sender, StylusDownEventArgs e)
        {
            UIElement el = sender as UIElement;

            //自由線
            if (isFreeLine)
            {
                dragging = true;
                points   = new List <System.Windows.Point>();
                points.Add(e.GetPosition(el));

                prevP = e.GetPosition(el);
            }

            //直線
            else
            {
                dragging = true;
                startP   = e.GetPosition(el);
            }
        }
Exemple #16
0
        private static void Target_OnStylusDown(object sender, StylusDownEventArgs e)
        {
            var casted = Start(sender, e.GetPosition((IInputElement)sender), eDrawingSource.Stylus);

            if (casted == null)
            {
                return;
            }

            casted.CaptureStylus();
            casted.StylusMove += Target_OnStylusMove;
            casted.StylusUp   += Target_OnStyulsUp;
        }
Exemple #17
0
        private void ElementOnStylusDown(object sender, StylusDownEventArgs e)
        {
            if (stylusId == -1)
            {
                var id      = e.StylusDevice.Id;
                var element = (FrameworkElement)sender;

                var parent = (UIElement)element.Parent;
                var point  = e.GetPosition(parent);

                OnDown(element, point);

                stylusId = id;
                element.CaptureStylus();
            }
        }
        private void ButtonFake_StylusDown(Image TargetButton, FrickData fd, StylusDownEventArgs e)
        {
            Stylus.Capture(TargetButton);
            Point pos = e.GetPosition(TargetButton);

            dStartPointX             = pos.X;
            dStartPointY             = pos.Y;
            FrickPopImage.Source     = PopImageC;
            PopTextC.Text            = fd.PopText[0];
            PopTextU.Text            = fd.PopText[1];
            PopTextD.Text            = fd.PopText[2];
            PopTextL.Text            = fd.PopText[3];
            PopTextR.Text            = fd.PopText[4];
            FrickPop.PlacementTarget = TargetButton;
            FrickPop.IsOpen          = true;
        }
Exemple #19
0
        /// <summary>
        /// Returns an awaitable Task that transform a StylusDown event in a StylusDown&Hold event
        /// </summary>
        /// <param name="originalEvent">Original StylusDown event</param>
        /// <param name="element">Original touched Control</param>
        /// <param name="msDuration">Duration before considering the StylusDown event as a StylusDown&Hold event</param>
        /// <param name="pxDelta">Circle radius in witch the StylusDown event must stay to be considered as a StylusDown&Hold event</param>
        /// <returns>Returns an awaitable Task that returns a Boolean</returns>
        public static Task <bool> StylusHold(StylusDownEventArgs originalEvent, FrameworkElement element, int msDuration,
                                             int pxDelta)
        {
            var originalPosition = originalEvent.GetPosition(element);
            var task             = new TaskCompletionSource <bool>();
            var timer            = new DispatcherTimer();

            timer.Interval = TimeSpan.FromMilliseconds(msDuration);

            StylusEventHandler stylusUpHandler = (o, e) =>
            {
                timer.Stop();
                if (task.Task.Status == TaskStatus.Running)
                {
                    task.SetResult(false);
                }
            };

            StylusEventHandler stylusMoveHandler = (o, e) =>
            {
                var currentPosition = e.GetPosition(element);
                if (Distance(currentPosition, originalPosition) > pxDelta)
                {
                    timer.Stop();
                    if (task.Task.Status == TaskStatus.Running)
                    {
                        task.SetResult(false);
                    }
                }
            };

            element.PreviewStylusUp   += stylusUpHandler;
            element.PreviewStylusMove += stylusMoveHandler;

            timer.Tick += delegate
            {
                element.PreviewStylusUp   -= stylusUpHandler;
                element.PreviewStylusMove -= stylusMoveHandler;
                timer.Stop();
                task.SetResult(true);
            };

            timer.Start();
            return(task.Task);
        }
Exemple #20
0
        protected override void OnPreviewStylusDown(StylusDownEventArgs e)
        {
            if (_numTouches == 0)
            {
                CaptureStylus();
                _inZooming = false;
            }

            if (_numTouches < 2)
            {
                _touchId[_numTouches]         = e.StylusDevice.Id;
                _touchInitialPts[_numTouches] = e.GetPosition(_canvas);
                _touchLastPts[_numTouches]    = _touchInitialPts[_numTouches];

                ++_numTouches;
            }
            e.Handled = true;
        }
        private void ButtonFake_StylusDown(object sender, StylusDownEventArgs e)
        {
            Stylus.Capture((Image)sender);
            Point pos = e.GetPosition((Image)sender);

            dStartPointX = pos.X;
            dStartPointY = pos.Y;
            int id = fblist.FindIndex(delegate(Image im) { return(sender.Equals(im)); });

            FrickPopImage.Source     = PopImageC;
            PopTextC.Text            = fd[id].PopText[0];
            PopTextU.Text            = fd[id].PopText[1];
            PopTextD.Text            = fd[id].PopText[2];
            PopTextL.Text            = fd[id].PopText[3];
            PopTextR.Text            = fd[id].PopText[4];
            FrickPop.PlacementTarget = (Image)sender;
            FrickPop.IsOpen          = true;
        }
        protected override void OnStylusDown(StylusDownEventArgs args)
        {
            base.OnStylusDown(args);
            Point ptStylus = args.GetPosition(canv);

            // create base object
            polyStylus = new Polyline()
            {
                Stroke             = brushStylus,
                StrokeThickness    = widthStroke,
                StrokeStartLineCap = PenLineCap.Round,
                StrokeEndLineCap   = PenLineCap.Round,
                StrokeLineJoin     = PenLineJoin.Round,
                Points             = new PointCollection()
            };
            polyStylus.Points.Add(ptStylus);

            // create shadow object
            polyShadow = new Polyline()
            {
                Stroke             = brushShadow,
                StrokeThickness    = widthStroke,
                StrokeStartLineCap = PenLineCap.Round,
                StrokeEndLineCap   = PenLineCap.Round,
                StrokeLineJoin     = PenLineJoin.Round,
                Points             = new PointCollection()
            };
            polyShadow.Points.Add(ptStylus + vectShadow);

            // insert shadow before the front polyline
            canv.Children.Insert(canv.Children.Count / 2, polyShadow);

            // front polyline
            canv.Children.Add(polyStylus);

            CaptureStylus();
            isDrawing    = true;
            args.Handled = true;
        }
        private void Grid_StylusDown(object sender, StylusDownEventArgs e)
        {
            Point currentPosition = e.GetPosition(Grid1);

            DrawStart(currentPosition);
        }
Exemple #24
0
 void CardEditView_PreviewStylusDown(object sender, StylusDownEventArgs e)
 {
     SelectionCheck(e.GetPosition((UIElement)this));
 }
Exemple #25
0
 private void TargetImagePreviewContactDown(object sender, StylusDownEventArgs e)
 {
     e.StylusDevice.Capture(_targetImage, CaptureMode.SubTree);
     _manipulationProcessor.ProcessDown((uint)e.StylusDevice.Id, e.GetPosition(_targetImage).ToDrawingPointF());
     e.Handled = true;
 }
 private void CommentBgStylusDown(object sender, StylusDownEventArgs e)
 {
     this.InputDown(e.GetPosition(this._adornedElement), e.GetPosition(this._comment));
 }
Exemple #27
0
 public override void StylusDown(EditorContext context, StylusDownEventArgs args)
 {
     isPressed |= 8;
     lastPos    = args.GetPosition(context.EditorControl);
 }
Exemple #28
0
 void LayoutRoot_StylusDown(object sender, StylusDownEventArgs e)
 {
     Emitter.EmitLocation = e.GetPosition(Emitter);
     Emitter.IsEmitting   = true;
 }