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; }
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 AssociatedObject_PreviewStylusDown(object sender, System.Windows.Input.StylusDownEventArgs e) { if ((e.StylusDevice.TabletDevice != null) && (e.StylusDevice.TabletDevice.Type != TabletDeviceType.Stylus)) { //touch임, pen 아님 return; } e.Handled = true; }
private void OnInkCanvasPreviewStylusDown(object sender, System.Windows.Input.StylusDownEventArgs e) { if (e.StylusDevice.TabletDevice.Type != TabletDeviceType.Stylus) { return; } this.InkCanvas.EditingMode = InkCanvasEditingMode.Ink; }
/// <summary> /// Tells the nearby shape that it's being rotated (if there's one) and hides the others. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void sketchPanel_StylusDown(object sender, System.Windows.Input.StylusDownEventArgs e) { // Remove all gates on a pen down no matter what RemoveAllGates(); // If we're erasing or not rotating gates, don't do anything else if (e.StylusDevice.Inverted || !RotateGates) { return; } // Clear past information activatedGate = null; // Get the nearest shape System.Windows.Point clickPoint = e.GetPosition(sketchPanel.InkCanvas); Shape nearbyShape = sketchPanel.Sketch.shapeAtPoint(clickPoint.X, clickPoint.Y, 100); // Only rotate AlreadyLabeled shapes if (nearbyShape == null || !nearbyShape.AlreadyLabeled) { return; } // Get the ghost gate for this shape DrawFeedback(nearbyShape, true); if (!ShapeToGate.ContainsKey(nearbyShape)) { return; } GhostGate nearbyGate = ShapeToGate[nearbyShape]; // If there was a viable gate nearby, activate it if (nearbyGate.canActivate(clickPoint)) { activatedGate = nearbyGate; activatedGate.activate(clickPoint); sketchPanel.UseCustomCursor = true; sketchPanel.Cursor = Cursors.Hand; sketchPanel.DisableDrawing(); } // Otherwise, take away the gate we just drew else { RemoveAllGates(); } }
/// <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; }
protected virtual void OnStylusDown(StylusDownEventArgs e) { throw new NotImplementedException (); }
protected virtual void OnStylusDown(StylusDownEventArgs e);
void PromoteRawToPreview(RawStylusInputReport report, ProcessInputEventArgs e) { RoutedEvent routedEvent = GetPreviewEventFromRawStylusActions(report.Actions); if (routedEvent != null && report.StylusDevice != null && !report.StylusDevice.IgnoreStroke) { StylusEventArgs args; if (routedEvent != Stylus.PreviewStylusSystemGestureEvent) { if (routedEvent == Stylus.PreviewStylusDownEvent) { args = new StylusDownEventArgs(report.StylusDevice, report.Timestamp); } else { args = new StylusEventArgs(report.StylusDevice, report.Timestamp); } } else { RawStylusSystemGestureInputReport reportSg = (RawStylusSystemGestureInputReport)report; args = new StylusSystemGestureEventArgs(report.StylusDevice, report.Timestamp, reportSg.SystemGesture, reportSg.GestureX, reportSg.GestureY, reportSg.ButtonState); } args.InputReport = report; args.RoutedEvent= routedEvent; e.PushInput(args, e.StagingItem); } }
public new void StylusDown(object sender, StylusDownEventArgs e) { this.TruthTableInkCanvas.ShowInkAnalysisFeedback = true; }
void CardEditView_PreviewStylusDown(object sender, StylusDownEventArgs e) { SelectionCheck(e.GetPosition((UIElement)this)); }
void SuggestionCanvas_StylusDown(object sender, StylusDownEventArgs e) { ChooseSuggestion(sender as InkCanvas); }
protected override void OnStylusDown(StylusDownEventArgs e) { base.OnStylusDown(e); }
private void GridStylusDown(object sender, StylusDownEventArgs e) { _downPoints = e.GetStylusPoints(MainImage); }
public new void StylusDown(object sender, StylusDownEventArgs e) { this.inkCanvas.circuitInkCanvas_StylusDown(sender, e); }
void invoker_StylusDown(object sender, StylusDownEventArgs e) { this.OnStylusDown(e); }
private void cProbe_StylusDown(object sender, StylusDownEventArgs e) { DisplayEvent("StylusDown", e.ToText()); }
/* * Expression User Control: No * TruthTable User Control: Yes * Diagram User Control: Yes * */ protected override void OnStylusDown(StylusDownEventArgs e) { if (e.StylusDevice.TabletDevice.Type == TabletDeviceType.Touch) { if (!TouchEnabled) { InputDevice = e.StylusDevice.TabletDevice.Type; return; } }else { InputDevice = e.StylusDevice.TabletDevice.Type; } base.OnStylusDown(e); foreach (UIElement child in Children) { if (child is IPassable) { if (child is LogicPad2.Expression.UserControl1) { #region Expression User Control //HitTest Point pt = e.GetPosition(this); HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(pt)); if (result != null) { LogicPad2.Expression.UserControl1 expressionUserControl = child as LogicPad2.Expression.UserControl1; CurrentDrawingControl = LogicCanvasType.Expression; HighLightCurrentUserControl(CurrentDrawingControl, expressionUserControl as UserControl); //Check HitTest Result on InkCanvas result = VisualTreeHelper.HitTest(expressionUserControl.ExpressionInkCanvas, this.TransformToDescendant(expressionUserControl.ExpressionInkCanvas).Transform(pt)); if (result != null) { expressionUserControl.UserControlStatus = UserControlStatus.Inking; (child as IPassable).StylusDown(this, e); return; } //Check HitTest Result on Scale Button result = VisualTreeHelper.HitTest(expressionUserControl.ScaleButton, this.TransformToDescendant(expressionUserControl.ScaleButton).Transform(pt)); if (result != null) { expressionUserControl.CaptureStylus(); expressionUserControl.UserControlStatus = UserControlStatus.Scale; expressionUserControl.InitBtmX = e.GetPosition(this).X; return; } //Check HitTest Result on Transform Button result = VisualTreeHelper.HitTest(expressionUserControl.TransformButton, this.TransformToDescendant(expressionUserControl.TransformButton).Transform(pt)); if (result != null) { expressionUserControl.CaptureStylus(); expressionUserControl.UserControlStatus = UserControlStatus.Transform; return; } return; } #endregion } else if (child is LogicPad2.TruthTable.UserControl1) { #region Truth Table User Control //HitTest Point pt = e.GetPosition(this); HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(pt)); if (result != null) { LogicPad2.TruthTable.UserControl1 truthTableUserControl = child as LogicPad2.TruthTable.UserControl1; CurrentDrawingControl = LogicCanvasType.TruthTable; HighLightCurrentUserControl(CurrentDrawingControl, truthTableUserControl as UserControl); //Check HitTest Result on InkCanvas result = VisualTreeHelper.HitTest(truthTableUserControl.TruthTableInkCanvas, this.TransformToDescendant(truthTableUserControl.TruthTableInkCanvas).Transform(pt)); if (result != null) { truthTableUserControl.UserControlStatus = UserControlStatus.Inking; (child as IPassable).StylusDown(this, e); return; } //Check HitTest Result on Scale Button result = VisualTreeHelper.HitTest(truthTableUserControl.ScaleButton, this.TransformToDescendant(truthTableUserControl.ScaleButton).Transform(pt)); if (result != null) { truthTableUserControl.UserControlStatus = UserControlStatus.Scale; truthTableUserControl.InitBtmX = e.GetPosition(this).X; return; } //Check HitTest Result on Transform Button result = VisualTreeHelper.HitTest(truthTableUserControl.TransformButton, this.TransformToDescendant(truthTableUserControl.TransformButton).Transform(pt)); if (result != null) { truthTableUserControl.UserControlStatus = UserControlStatus.Transform; return; } return; } #endregion } else if (child is LogicPad2.Diagram.UserControl1) { #region Diagram User Control //HitTest Point pt = e.GetPosition(this); HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(pt)); if (result != null) { LogicPad2.Diagram.UserControl1 diagramUserControl = child as LogicPad2.Diagram.UserControl1; CurrentDrawingControl = LogicCanvasType.Diagram; HighLightCurrentUserControl(LogicCanvasType.Diagram, diagramUserControl); //Check HitTest Result on InkCanvas result = VisualTreeHelper.HitTest(diagramUserControl.DiagramInkCanvas, this.TransformToDescendant(diagramUserControl.DiagramInkCanvas).Transform(pt)); if (result != null) { diagramUserControl.UserControlStatus = UserControlStatus.Inking; (child as IPassable).StylusDown(this, e); return; } //Check HitTest Result on Scale Button result = VisualTreeHelper.HitTest(diagramUserControl.ScaleButton, this.TransformToDescendant(diagramUserControl.ScaleButton).Transform(pt)); if (result != null) { diagramUserControl.UserControlStatus = UserControlStatus.Scale; diagramUserControl.InitBtmX = e.GetPosition(this).X; return; } //Check HitTest Result on Transform Button result = VisualTreeHelper.HitTest(diagramUserControl.TransformButton, this.TransformToDescendant(diagramUserControl.TransformButton).Transform(pt)); if (result != null) { diagramUserControl.UserControlStatus = UserControlStatus.Transform; diagramUserControl.InitBtmX = e.GetPosition(this).X; diagramUserControl.InitBtmY = e.GetPosition(this).Y; return; } return; } #endregion } else if (child is ExpressionWindow.ExpressionRepresentation) { #region Expression Representation //HitTest Point pt = e.GetPosition(this); HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(pt)); if (result != null) { ExpressionWindow.ExpressionRepresentation expressionRepr = child as ExpressionWindow.ExpressionRepresentation; //Check HitTest Result on Scale Button result = VisualTreeHelper.HitTest(expressionRepr.ScaleButton, this.TransformToDescendant(expressionRepr.ScaleButton).Transform(pt)); if (result != null) { expressionRepr.UserControlStatus = UserControlStatus.Scale; expressionRepr.InitBtmX = e.GetPosition(this).X; return; } //Check HitTest Result on Transform Button result = VisualTreeHelper.HitTest(expressionRepr.TransformButton, this.TransformToDescendant(expressionRepr.TransformButton).Transform(pt)); if (result != null) { expressionRepr.UserControlStatus = UserControlStatus.Transform; return; } return; } #endregion } else if (child is TruthTableWindow.TruthTableRepresentation) { #region TruthTable Representation //HitTest Point pt = e.GetPosition(this); HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(pt)); if (result != null) { TruthTableWindow.TruthTableRepresentation truthTableRepr = child as TruthTableWindow.TruthTableRepresentation; //Check HitTest Result on Scale Button result = VisualTreeHelper.HitTest(truthTableRepr.ScaleButton, this.TransformToDescendant(truthTableRepr.ScaleButton).Transform(pt)); if (result != null) { truthTableRepr.UserControlStatus = UserControlStatus.Scale; truthTableRepr.InitBtmX = e.GetPosition(this).X; return; } //Check HitTest Result on Transform Button result = VisualTreeHelper.HitTest(truthTableRepr.TransformButton, this.TransformToDescendant(truthTableRepr.TransformButton).Transform(pt)); if (result != null) { truthTableRepr.UserControlStatus = UserControlStatus.Transform; return; } return; } #endregion } else if (child is GatesWpf.DiagramRepresentation) { #region Diagram Representation //HitTest Point pt = e.GetPosition(this); HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(pt)); if (result != null) { GatesWpf.DiagramRepresentation diagramRepr = child as GatesWpf.DiagramRepresentation; //Check HitTest Result on Scale Button result = VisualTreeHelper.HitTest(diagramRepr.ScaleButton, this.TransformToDescendant(diagramRepr.ScaleButton).Transform(pt)); if (result != null) { diagramRepr.UserControlStatus = UserControlStatus.Scale; diagramRepr.InitBtmX = e.GetPosition(this).X; return; } //Check HitTest Result on Transform Button result = VisualTreeHelper.HitTest(diagramRepr.TransformButton, this.TransformToDescendant(diagramRepr.TransformButton).Transform(pt)); if (result != null) { diagramRepr.UserControlStatus = UserControlStatus.Transform; return; } return; } #endregion } } } CurrentDrawingControl = LogicCanvasType.Main; ChangeMainMenuRepresentationOptions(this, new MenuEventArgs(LogicCanvasType.Main)); }
/* * Expression User Control: Yes * TruthTable User Control: No * Diagram User Control: No * */ protected override void OnPreviewStylusDown(StylusDownEventArgs e) { base.OnPreviewStylusDown(e); foreach (UIElement child in Children) { if (child is IPassable) { if (child is LogicPad2.Expression.UserControl1) { #region Expression User Control Point pt = e.GetPosition(this); HitTestResult result = VisualTreeHelper.HitTest(child, this.TransformToDescendant(child).Transform(pt)); if (result != null) { LogicPad2.Expression.UserControl1 expressionUserControl = child as LogicPad2.Expression.UserControl1; //Check HitTest Result on InkCanvas result = VisualTreeHelper.HitTest(expressionUserControl.ExpressionInkCanvas, this.TransformToDescendant(expressionUserControl.ExpressionInkCanvas).Transform(pt)); if (result != null) { expressionUserControl.UserControlStatus = UserControlStatus.Inking; (child as IPassable).PreviewStylusDown(this, e); return; } } #endregion } } } }
private void Grid_StylusDown(object sender, StylusDownEventArgs e) { Point currentPosition = e.GetPosition(Grid1); DrawStart(currentPosition); }
private void DrawingCanvas_PreviewStylusDown(object sender, StylusDownEventArgs e) { //System.Diagnostics.Debug.WriteLine("DrawingCanvas_PreviewStylusDown [펜을 캔버스에 대면 자동적으로 쓰기모드]"); //펜을 캔버스에 대면 자동적으로 쓰기모드 //this.llbTools.SelectedIndex = 1; }
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> /// Virtual method reporting a stylus-down /// </summary> protected virtual void OnPreviewStylusDown(StylusDownEventArgs e) {}
void MainWindowStylusDown(object sender, StylusDownEventArgs e) { DoTapDown(); }
void PromotePreviewToMain(ProcessInputEventArgs e) { if (!e.StagingItem.Input.Handled) { RoutedEvent eventMain = GetMainEventFromPreviewEvent(e.StagingItem.Input.RoutedEvent); if (eventMain != null) { StylusEventArgs eventArgsPreview = (StylusEventArgs)e.StagingItem.Input; StylusDevice stylusDevice = eventArgsPreview.InputReport.StylusDevice; StylusEventArgs eventArgsMain; if (eventMain == Stylus.StylusDownEvent || eventMain == Stylus.PreviewStylusDownEvent) { StylusDownEventArgs downEventArgsPreview = (StylusDownEventArgs)eventArgsPreview; eventArgsMain = new StylusDownEventArgs(stylusDevice, eventArgsPreview.Timestamp); } else if (eventMain == Stylus.StylusButtonDownEvent || eventMain == Stylus.StylusButtonUpEvent) { StylusButtonEventArgs buttonEventArgsPreview = (StylusButtonEventArgs)eventArgsPreview; eventArgsMain = new StylusButtonEventArgs(stylusDevice, eventArgsPreview.Timestamp, buttonEventArgsPreview.StylusButton); } else if (eventMain != Stylus.StylusSystemGestureEvent) { eventArgsMain = new StylusEventArgs(stylusDevice, eventArgsPreview.Timestamp); } else { StylusSystemGestureEventArgs previewSystemGesture = (StylusSystemGestureEventArgs)eventArgsPreview; eventArgsMain = new StylusSystemGestureEventArgs(stylusDevice, previewSystemGesture.Timestamp, previewSystemGesture.SystemGesture, previewSystemGesture.GestureX, previewSystemGesture.GestureY, previewSystemGesture.ButtonState); } eventArgsMain.InputReport = eventArgsPreview.InputReport; eventArgsMain.RoutedEvent = eventMain; e.PushInput(eventArgsMain, e.StagingItem); } } else { // A TouchDevice is activated before TouchDown and deactivated after TouchUp // But if PreviewStylusUp event is handled by the user, it will // never be promoted to TouchUp event leaving the TouchDevice in inconsistent // active state. Hence deactivating touch device if it is active. StylusEventArgs stylusEventArgs = e.StagingItem.Input as StylusEventArgs; if (stylusEventArgs != null && stylusEventArgs.RoutedEvent == Stylus.PreviewStylusUpEvent && stylusEventArgs.StylusDevice.TouchDevice.IsActive) { stylusEventArgs.StylusDevice.TouchDevice.OnDeactivate(); } } }
private static void OnStylusDownThunk(object sender, StylusDownEventArgs e) { Invariant.Assert(!e.Handled, "Unexpected: Event has already been handled."); UIElement uie = sender as UIElement; if (uie != null) { uie.OnStylusDown(e); } else { ContentElement ce = sender as ContentElement; if (ce != null) { ce.OnStylusDown(e); } else { ((UIElement3D)sender).OnStylusDown(e); } } }
public new void PreviewStylusDown(object sender, StylusDownEventArgs e) { }
/// <summary> /// Virtual method reporting a stylus-down /// </summary> protected internal virtual void OnStylusDown(StylusDownEventArgs e) {}
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); } }
protected override void OnStylusDown(StylusDownEventArgs e) { base.OnStylusDown(e); if(TouchEnabled && CanDragMap && !e.InAir) { Point p = e.GetPosition(this); if(MapScaleTransform != null) { p = MapScaleTransform.Inverse.Transform(p); } p = ApplyRotationInversion(p.X, p.Y); Core.mouseDown.X = (int)p.X; Core.mouseDown.Y = (int)p.Y; InvalidateVisual(); } }
protected override void OnStylusDown(StylusDownEventArgs e) { if(TouchEnabled && CanDragMap && !e.InAir) { Mouse.Capture(this); System.Windows.Point p = e.GetPosition(this); if(MapRenderTransform != null) { p = MapRenderTransform.Inverse.Transform(p); } p = ApplyRotationInversion(p.X, p.Y); Core.mouseDown.X = (int) p.X; Core.mouseDown.Y = (int) p.Y; { Cursor = Cursors.SizeAll; Core.BeginDrag(Core.mouseDown); } InvalidateVisual(); } base.OnStylusDown(e); }
//pie menu only public void circuitInkCanvas_StylusDown(object sender, StylusDownEventArgs e) { StylusPointCollection points = e.GetStylusPoints(this.circuitInkCanvas); _stylusDownTime = DateTime.Now; StartPoint = points[0]; IsPieMenuVisible = false; }
void Emitter_StylusDown(object sender, StylusDownEventArgs e) { Emitter.EmitLocation = e.GetPosition(Emitter); Emitter.IsEmitting = true; }